package com.mes.web.controller.lf;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mes.entity.lf.Nogood;
import com.mes.entity.tdd.Staff;
import com.mes.service.lf.DeviceService;
import com.mes.service.lf.NogoodService;
import com.mes.utils.ResponseUtil;

/**
 * 作业信息的controller层
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/homeworkInfo")
public class HomeWorkController {

	@Resource
	NogoodService nogoodService;
	
	@Resource
	DeviceService deviceService;
	
	/**
	 * 添加不良品记录
	 * @param response
	 * @param nogood
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping("/addNoGood")
	public void addNoGood(HttpServletResponse response, Nogood nogood, HttpSession session) throws Exception{
		String str = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); 
		
		//获取当前登录人为登记者
		Staff staff = (Staff)session.getAttribute("staff");
		String name = staff.getStaffname();
		//保存到不良表中
		nogood.setWritetime(str);
		nogood.setRegistrar(name);
		nogoodService.add(nogood);
		Integer flag = nogood.getAffect();
		//System.out.println(flag);
		ResponseUtil.write(response, flag);
	}
	
	@ResponseBody
	@RequestMapping("/findNogoodByCondetion")
	public void findNogoodByCondetion(){
		
	}
	
	@ResponseBody
	@RequestMapping("/saveTo")
	public void saveTo(){
		System.out.println("什么鬼");
	}
}
